# 本脚本的任务是要产生多个异常区域

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import random


df = pd.read_csv('../data/data_history/data_1809_(15,20000).csv', header=None)

arr = df.values

print(arr.shape)

# for i in range(90):
#     arr[0, 12000 + i] = 100
maxs = np.max(arr, axis=1)
mins = np.min(arr, axis=1)
means = np.mean(arr, axis=1)

# 第一处异常 直线型 0 1 2 3
for j in range(4):
    y_max = maxs[j]
    y_min = mins[j]
    for i in range(90):
        arr[j, 12000 + i] = y_max

for j in range(4):
    y_max = maxs[j]
    y_min = mins[j]
    for i in range(200):
        arr[j, 14000 + i] = y_max


x = np.arange(-2*np.pi,2*np.pi,0.01)

# 增加的第二处异常 正弦型 9 10 11 12
# for j in range(9, 13):
#     y_max = maxs[j]
#     y_min = mins[j]
#     y = y_max * np.sin(x)
#     for i in range(90):
#         arr[j, 14000 + i] = y[i]

# # # 增加的第三处异常 扩展型
# idx = [0, 1, 2, 3, 9, 10, 11, 12]
# for j in range(len(idx)):
#     y_max = maxs[idx[j]]
#     y_min = mins[idx[j]]
#     y = y_max * np.sin(x)
#     for i in range(90):
#         arr[idx[j], 17000 + i] = y[i]*arr[idx[j], 17000 + i]


# 增加的第四处异常 锯齿
# ids = [13, 14]
# for j in range(len(ids)):
#     m = means[ids[j]]
#     y_max = maxs[ids[j]]
#     y_min = mins[ids[j]]
#     for i in range(90):
#         arr[ids[j], 19000 + i] = arr[ids[j], 19000 + i] + y_max


# print(count)
np.savetxt('../data/data_testAno_2.csv', arr, delimiter=',')